{% extends "rules/base.html" %}
{% load bootstrap3 %}
{% block sidebar %}
    <div class="panel-heading">
        <h2 class="panel-title">Add {{ type }} for rule {{ rule.pk }}</h2>
    </div>
    <div class="panel-body">
        <ul class="action">
            {% if rule.state %}
                <li>
                    <a href="{% url 'edit_rule' rule.sid %}">Transform rule</a>
                </li>
                <li>
                    <a href="{% url 'disable_rule' rule.sid %}">Disable rule</a>
                </li>
                <li>
                    <a href="{% url 'enable_rule' rule.sid %}">Enable rule</a>
                </li>
                <li>
                    <a href="{% url 'threshold_rule' rule.sid %}?action=threshold">Threshold rule</a>
                </li>
                <li>
                    <a href="{% url 'threshold_rule' rule.sid %}?action=suppress">Suppress rule</a>
                </li>
            {% endif %}
            {# rule.state #}
        </ul>
    </div>
{% endblock sidebar %}
{% block content %}
    {% if missing %}
        {{ missing }}
    {% else %}
        {% if containers %}
            <div class="alert alert-danger">
                Depending on the chosen ruleset, the threshold could be included in the following thresholds.
                <h3>Containing thresholds</h3>
                {% load render_table from django_tables2 %}
                {% render_table containers %}
            </div>
        {% endif %}
        {% if thresholds %}
            <h2>Existing thresholds</h2>
            {% load render_table from django_tables2 %}
            {% render_table thresholds %}
        {% endif %}
        {% if form %}
            <h2>Add {{ type }}</h2>
            <div class="container-fluid">
                <div class="row">
                    <div class="col-md-6">
                        <form action="{% url 'threshold_rule' rule.pk %}"
                              method="post"
                              class="form">
                            {% csrf_token %}
                            {% bootstrap_form form %}
                            {% buttons %}
                            <button type="submit" class="btn btn-primary">{% bootstrap_icon "plus" %} Add</button>
                        {% endbuttons %}
                    </form>
                </div>
            </div>
        </div>
    {% endif %}
{% endif %}
{% endblock content %}
